#include <Editor/StdAfx.h>
#include "NewUnitDialog.h"
#include "GameToolApp.h"
#include <GameLib/Database.h>

enum IDS_FOR_NEW_UNIT_DIALOG
{
	ID_CLASS_COMBO = wxID_HIGHEST+1,
};
NewUnitDialog::NewUnitDialog(wxWindow* parent, wxWindowID id, const wxString& title, const wxSize& size)
	: wxDialog(parent, id, title, wxDefaultPosition, size)

{
	wxBoxSizer* topSizer = new wxBoxSizer( wxVERTICAL);
	SetSizer(topSizer);

	// TERRAIN CREATION START ---
		wxStaticBoxSizer* creationSizer =new wxStaticBoxSizer(new wxStaticBox(this, wxID_ANY, _("New Unit")), wxVERTICAL);
		topSizer->Add(creationSizer, wxSizerFlags().Expand().Border());
		// Class
		wxBoxSizer* classSizer = new wxBoxSizer( wxHORIZONTAL );
		creationSizer->Add(classSizer);
		wxArrayString classStrings;
		unsigned numClasses = Database::getSingleton().GetUnitTemplates().msData.size();
		for (unsigned i=0; i< numClasses; i++)
		{
			classStrings.Add(wxString(Database::getSingleton().GetUnitTemplates().msData[i].mClass.c_str(), gCSConv));
		}
		mClassComboBox = 
			new wxComboBox(this, ID_CLASS_COMBO, *classStrings.begin(), wxDefaultPosition, wxDefaultSize, classStrings, wxCB_DROPDOWN | wxCB_READONLY);
		classSizer->Add( mClassComboBox, wxSizerFlags().Border().Expand() );

	// --- TERRAIN CREATION END

	wxSizer* buttonSizer = CreateButtonSizer(wxOK|wxCANCEL);
	topSizer->Add(buttonSizer, wxSizerFlags().Border().Center());
	Layout();
}

unsigned NewUnitDialog::GetUnitTemplateID()
{
	wxString strClass = mClassComboBox->GetValue();
	unsigned id = Database::getSingleton().GetUnitTemplateIDByClass(strClass.mb_str());
	return id;
}